#ifndef GENE_H_
#define GENE_H_

#include <vector>
#include <cstdlib>

template <typename T>
class Gene
{
public:
	Gene(unsigned int num_pieces)
	{
		for (unsigned int i = 0; i < num_pieces; i++)
		{
			pieces.push_back((T)0);
		}
	}

	virtual ~Gene()
	{
	}
	
	T &operator[](unsigned int offset)
	{
		if(offset > pieces.size())
		{
			return pieces[pieces.size() - 1];
		}

		return pieces[offset];
	}
	
	void randomise_data(T lower_bound, T upper_bound)
	{
		for (unsigned int i = 0; i < pieces.size(); i++)
		{
			pieces[i] = (T)((((double)rand() / RAND_MAX) * (upper_bound - lower_bound)) + lower_bound);
		}
	}
	
	unsigned int get_num_pieces() const
	{
		return pieces.size();
	}
	
private:
	std::vector<T> pieces;
};

#endif /*GENE_H_*/
